package com.cn.pack.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @RequestMapping(path = "/hello/say")
    @HystrixCommand(fallbackMethod = "defaultSay")
    public String say(@RequestParam("id") String id) throws Exception {
        if ("999".equals(id)) {
            throw new Exception();
        }
        return "id = " + id;
    }

    public String defaultSay(String id) {
        return "error。。。";
    }
}
